/*初始化数据表格*/
function initTable() {
    var url=getBasePath()+'/mdm/logipoint/getListData.json';
    var tableId="table_data";
    $("#"+tableId).dataTable().fnDestroy();
    json = {};
    json.showLineNuber = false;
    json.id = tableId;
    json.pagesize=2;
    json.url = url ;
    json.param = [
        {"name": "pointId", "value": $.trim($("#pointId").val())},
        {"name": "pointCode", "value": $.trim($("#pointCode").val())},
        {"name": "pointName", "value": $.trim($("#pointName").val())},
        {"name": "orgType", "value": $.trim($("#orgType").val())},
        {"name": "companyCode", "value": $.trim($("#companyCode").val())},
        {"name": "dealerCode", "value": $.trim($("#dealerCode").val())},
        {"name": "nationCode", "value": $.trim($("#nationCode").val())},
        {"name": "provinceCode", "value": $.trim($("#provinceCode").val())},
        {"name": "cityCode", "value": $.trim($("#cityCode").val())},
        {"name": "districtCode", "value": $.trim($("#districtCode").val())},
        {"name": "street", "value": $.trim($("#street").val())},
        {"name": "address", "value": $.trim($("#address").val())},
        {"name": "postcode", "value": $.trim($("#postcode").val())},
        {"name": "contact", "value": $.trim($("#contact").val())},
        {"name": "mobiPhone", "value": $.trim($("#mobiPhone").val())},
        {"name": "tel", "value": $.trim($("#tel").val())},
        {"name": "fax", "value": $.trim($("#fax").val())},
        {"name": "latitude", "value": $.trim($("#latitude").val())},
        {"name": "longitude", "value": $.trim($("#longitude").val())},
        {"name": "pointType", "value": $.trim($("#pointType").val())},
        {"name": "whPosition", "value": $.trim($("#whPosition").val())},
        {"name": "whSynchronize", "value": $.trim($("#whSynchronize").val())},
        {"name": "whNonconsign", "value": $.trim($("#whNonconsign").val())},
        {"name": "whParentId", "value": $.trim($("#whParentId").val())},
        {"name": "whProperty", "value": $.trim($("#whProperty").val())},
        {"name": "whCapacity", "value": $.trim($("#whCapacity").val())},
        {"name": "whInnerCapacity", "value": $.trim($("#whInnerCapacity").val())},
        {"name": "whOuterCapacity", "value": $.trim($("#whOuterCapacity").val())},
        {"name": "vhCapacity", "value": $.trim($("#vhCapacity").val())},
        {"name": "maxVhCapacity", "value": $.trim($("#maxVhCapacity").val())},
        {"name": "whPdi", "value": $.trim($("#whPdi").val())},
        {"name": "whDriveway", "value": $.trim($("#whDriveway").val())},
        {"name": "whCrossdock", "value": $.trim($("#whCrossdock").val())},
        {"name": "whOffline", "value": $.trim($("#whOffline").val())},
        {"name": "whWms", "value": $.trim($("#whWms").val())},
        {"name": "whRealwh", "value": $.trim($("#whRealwh").val())},
        {"name": "whStarttime", "value": $.trim($("#whStarttime").val())},
        {"name": "whEndtime", "value": $.trim($("#whEndtime").val())},
        {"name": "whLegacy", "value": $.trim($("#whLegacy").val())},
        {"name": "whArea", "value": $.trim($("#whArea").val())},
        {"name": "whEsc", "value": $.trim($("#whEsc").val())},
        {"name": "totalStore", "value": $.trim($("#totalStore").val())},
        {"name": "leadTime", "value": $.trim($("#leadTime").val())},
        {"name": "loadTime", "value": $.trim($("#loadTime").val())},
        {"name": "stdInterface", "value": $.trim($("#stdInterface").val())},
        {"name": "recordPhone", "value": $.trim($("#recordPhone").val())},
        {"name": "newDriveway", "value": $.trim($("#newDriveway").val())},
    ];
    json.columns = [
        {
            "mData": "logipointCode", "sWidth": "15%", "sClass": "text-center",
            "mRender": function (data, type, row) {
                if (data) {
					var detailStr="<a class='icondatatable' vb='详情' href=\"#\" onclick='toDetailPage(\""+data+"\");'><i class=\"icon-detail\"></i></a>";
                    var editStr="<a class='icondatatable' vb='修改' href=\"#\" onclick='toEditLogipoint(\""+data+"\");'><i class=\"icon-edit\"></i></a>";
                    var delStr="<a class='icondatatable' vb='删除' href=\"#\"  onclick='deleteLogipoint(\""+data+"\");'><i class=\"icon-bin\"></i></a>";

                    return detailStr+editStr+delStr;
                }
            }
        },
        {"mData": "pointId", "sClass": "text-center"},
        {"mData": "pointCode", "sClass": "text-center"},
        {"mData": "pointName", "sClass": "text-center"},
        {"mData": "orgType", "sClass": "text-center"},
        {"mData": "companyCode", "sClass": "text-center"},
        {"mData": "dealerCode", "sClass": "text-center"},
        {"mData": "nationCode", "sClass": "text-center"},
        {"mData": "provinceCode", "sClass": "text-center"},
        {"mData": "cityCode", "sClass": "text-center"},
        {"mData": "districtCode", "sClass": "text-center"},
        {"mData": "street", "sClass": "text-center"},
        {"mData": "address", "sClass": "text-center"},
        {"mData": "postcode", "sClass": "text-center"},
        {"mData": "contact", "sClass": "text-center"},
        {"mData": "mobiPhone", "sClass": "text-center"},
        {"mData": "tel", "sClass": "text-center"},
        {"mData": "fax", "sClass": "text-center"},
        {"mData": "latitude", "sClass": "text-center"},
        {"mData": "longitude", "sClass": "text-center"},
        {"mData": "pointType", "sClass": "text-center"},
        {"mData": "whPosition", "sClass": "text-center"},
        {"mData": "whSynchronize", "sClass": "text-center"},
        {"mData": "whNonconsign", "sClass": "text-center"},
        {"mData": "whParentId", "sClass": "text-center"},
        {"mData": "whProperty", "sClass": "text-center"},
        {"mData": "whCapacity", "sClass": "text-center"},
        {"mData": "whInnerCapacity", "sClass": "text-center"},
        {"mData": "whOuterCapacity", "sClass": "text-center"},
        {"mData": "vhCapacity", "sClass": "text-center"},
        {"mData": "maxVhCapacity", "sClass": "text-center"},
        {"mData": "whPdi", "sClass": "text-center"},
        {"mData": "whDriveway", "sClass": "text-center"},
        {"mData": "whCrossdock", "sClass": "text-center"},
        {"mData": "whOffline", "sClass": "text-center"},
        {"mData": "whWms", "sClass": "text-center"},
        {"mData": "whRealwh", "sClass": "text-center"},
        {"mData": "whStarttime", "sClass": "text-center"},
        {"mData": "whEndtime", "sClass": "text-center"},
        {"mData": "whLegacy", "sClass": "text-center"},
        {"mData": "whArea", "sClass": "text-center"},
        {"mData": "whEsc", "sClass": "text-center"},
        {"mData": "totalStore", "sClass": "text-center"},
        {"mData": "leadTime", "sClass": "text-center"},
        {"mData": "loadTime", "sClass": "text-center"},
        {"mData": "stdInterface", "sClass": "text-center"},
        {"mData": "recordPhone", "sClass": "text-center"},
        {"mData": "newDriveway", "sClass": "text-center"},
    ];
    var oTable1 = TableManaged(json).init();
}
/*查询数据*/
function doQuery(){
    initTable();
}


/*重置查询条件*/
function resetQueryForm(){
	$("#pointId").val('');
	$("#pointCode").val('');
	$("#pointName").val('');
	$("#orgType").val('');
	$("#companyCode").val('');
	$("#dealerCode").val('');
	$("#nationCode").val('');
	$("#provinceCode").val('');
	$("#cityCode").val('');
	$("#districtCode").val('');
	$("#street").val('');
	$("#address").val('');
	$("#postcode").val('');
	$("#contact").val('');
	$("#mobiPhone").val('');
	$("#tel").val('');
	$("#fax").val('');
	$("#latitude").val('');
	$("#longitude").val('');
	$("#pointType").val('');
	$("#whPosition").val('');
	$("#whSynchronize").val('');
	$("#whNonconsign").val('');
	$("#whParentId").val('');
	$("#whProperty").val('');
	$("#whCapacity").val('');
	$("#whInnerCapacity").val('');
	$("#whOuterCapacity").val('');
	$("#vhCapacity").val('');
	$("#maxVhCapacity").val('');
	$("#whPdi").val('');
	$("#whDriveway").val('');
	$("#whCrossdock").val('');
	$("#whOffline").val('');
	$("#whWms").val('');
	$("#whRealwh").val('');
	$("#whStarttime").val('');
	$("#whEndtime").val('');
	$("#whLegacy").val('');
	$("#whArea").val('');
	$("#whEsc").val('');
	$("#totalStore").val('');
	$("#leadTime").val('');
	$("#loadTime").val('');
	$("#stdInterface").val('');
	$("#recordPhone").val('');
	$("#newDriveway").val('');
}

/*删除数据*/
function deleteLogipoint(logipointCode){
    var _url=getBasePath()+'/mdm/logipoint/delete.json';
    $.Confirm('你确定要删除这条记录吗？','',function(){
        var logipoint={};
        logipoint.logipointCode=logipointCode;
        $.ajax({
            url:_url,
            type:'POST',
            dataType:'json',
            contentType:'application/json',
            data:JSON.stringify(logipoint),
            success:function(data){
                if(data.status==200){
                    $.Success('删除成功',doQuery);
                }else{
                    var msg = data.message || "删除物流运作点数据发生错误";
                    $.Error(msg,'',null);
                }
            }
        });
    });

}

/*跳转编辑数据页面*/
function toEditLogipoint(logipointCode){
    var _url=getBasePath()+'/mdm/logipoint/toEdit.htm?logipointCode='+logipointCode;
    location.href=_url;
}

/*编辑数据*/
function editLogipoint(){
    $validator =$("#logipoint_edit_form").validator('isFormValid');
    if(!$validator){
        return;
    }
    var _url=getBasePath()+'/mdm/logipoint/edit.json';
    var logipoint={};
	logipoint.pointId=$("#pointId").val();
	logipoint.pointCode=$("#pointCode").val();
	logipoint.pointName=$("#pointName").val();
	logipoint.orgType=$("#orgType").val();
	logipoint.companyCode=$("#companyCode").val();
	logipoint.dealerCode=$("#dealerCode").val();
	logipoint.nationCode=$("#nationCode").val();
	logipoint.provinceCode=$("#provinceCode").val();
	logipoint.cityCode=$("#cityCode").val();
	logipoint.districtCode=$("#districtCode").val();
	logipoint.street=$("#street").val();
	logipoint.address=$("#address").val();
	logipoint.postcode=$("#postcode").val();
	logipoint.contact=$("#contact").val();
	logipoint.mobiPhone=$("#mobiPhone").val();
	logipoint.tel=$("#tel").val();
	logipoint.fax=$("#fax").val();
	logipoint.latitude=$("#latitude").val();
	logipoint.longitude=$("#longitude").val();
	logipoint.pointType=$("#pointType").val();
	logipoint.whPosition=$("#whPosition").val();
	logipoint.whSynchronize=$("#whSynchronize").val();
	logipoint.whNonconsign=$("#whNonconsign").val();
	logipoint.whParentId=$("#whParentId").val();
	logipoint.whProperty=$("#whProperty").val();
	logipoint.whCapacity=$("#whCapacity").val();
	logipoint.whInnerCapacity=$("#whInnerCapacity").val();
	logipoint.whOuterCapacity=$("#whOuterCapacity").val();
	logipoint.vhCapacity=$("#vhCapacity").val();
	logipoint.maxVhCapacity=$("#maxVhCapacity").val();
	logipoint.whPdi=$("#whPdi").val();
	logipoint.whDriveway=$("#whDriveway").val();
	logipoint.whCrossdock=$("#whCrossdock").val();
	logipoint.whOffline=$("#whOffline").val();
	logipoint.whWms=$("#whWms").val();
	logipoint.whRealwh=$("#whRealwh").val();
	logipoint.whStarttime=$("#whStarttime").val();
	logipoint.whEndtime=$("#whEndtime").val();
	logipoint.whLegacy=$("#whLegacy").val();
	logipoint.whArea=$("#whArea").val();
	logipoint.whEsc=$("#whEsc").val();
	logipoint.totalStore=$("#totalStore").val();
	logipoint.leadTime=$("#leadTime").val();
	logipoint.loadTime=$("#loadTime").val();
	logipoint.stdInterface=$("#stdInterface").val();
	logipoint.recordPhone=$("#recordPhone").val();
	logipoint.newDriveway=$("#newDriveway").val();

    $.ajax({
        url:_url,
        type:'POST',
        dataType:'json',
        contentType:'application/json',
        data:JSON.stringify(logipoint),
        success:function(data){
            if(data.status==200){
                $.Success('该记录已提交成功!',gotoListPage);
            }else{
                var msg = data.message || "编辑物流运作点数据发生错误";
                $.Error(msg,'',null);
            }

        },
        error:function(data){
            JSON.stringify(data);
        }
    });
}

/*跳转新增数据页面*/
function toAddLogipoint(){
    var _url=getBasePath()+'/mdm/logipoint/toAdd.htm';
    location.href=_url;
}

/*新增数据*/
function saveLogipoint(){
    $validator =$("#logipoint_add_form").validator('isFormValid');
    if(!$validator){
        return;
    }
    var _url=getBasePath()+'/mdm/logipoint/add.json';
    var logipoint={};
	logipoint.pointId=$("#pointId").val();
	logipoint.pointCode=$("#pointCode").val();
	logipoint.pointName=$("#pointName").val();
	logipoint.orgType=$("#orgType").val();
	logipoint.companyCode=$("#companyCode").val();
	logipoint.dealerCode=$("#dealerCode").val();
	logipoint.nationCode=$("#nationCode").val();
	logipoint.provinceCode=$("#provinceCode").val();
	logipoint.cityCode=$("#cityCode").val();
	logipoint.districtCode=$("#districtCode").val();
	logipoint.street=$("#street").val();
	logipoint.address=$("#address").val();
	logipoint.postcode=$("#postcode").val();
	logipoint.contact=$("#contact").val();
	logipoint.mobiPhone=$("#mobiPhone").val();
	logipoint.tel=$("#tel").val();
	logipoint.fax=$("#fax").val();
	logipoint.latitude=$("#latitude").val();
	logipoint.longitude=$("#longitude").val();
	logipoint.pointType=$("#pointType").val();
	logipoint.whPosition=$("#whPosition").val();
	logipoint.whSynchronize=$("#whSynchronize").val();
	logipoint.whNonconsign=$("#whNonconsign").val();
	logipoint.whParentId=$("#whParentId").val();
	logipoint.whProperty=$("#whProperty").val();
	logipoint.whCapacity=$("#whCapacity").val();
	logipoint.whInnerCapacity=$("#whInnerCapacity").val();
	logipoint.whOuterCapacity=$("#whOuterCapacity").val();
	logipoint.vhCapacity=$("#vhCapacity").val();
	logipoint.maxVhCapacity=$("#maxVhCapacity").val();
	logipoint.whPdi=$("#whPdi").val();
	logipoint.whDriveway=$("#whDriveway").val();
	logipoint.whCrossdock=$("#whCrossdock").val();
	logipoint.whOffline=$("#whOffline").val();
	logipoint.whWms=$("#whWms").val();
	logipoint.whRealwh=$("#whRealwh").val();
	logipoint.whStarttime=$("#whStarttime").val();
	logipoint.whEndtime=$("#whEndtime").val();
	logipoint.whLegacy=$("#whLegacy").val();
	logipoint.whArea=$("#whArea").val();
	logipoint.whEsc=$("#whEsc").val();
	logipoint.totalStore=$("#totalStore").val();
	logipoint.leadTime=$("#leadTime").val();
	logipoint.loadTime=$("#loadTime").val();
	logipoint.stdInterface=$("#stdInterface").val();
	logipoint.recordPhone=$("#recordPhone").val();
	logipoint.newDriveway=$("#newDriveway").val();
    
    $.ajax({
        url:_url,
        type:'POST',
        dataType:'json',
        contentType:'application/json',
        data:JSON.stringify(logipoint),
        success:function(data){
            if(data.status==200){
                $.Success('该记录已提交成功!',gotoListPage);
            }else{
                var msg = data.message || "新增物流运作点数据发生错误";
                $.Error(msg,'',null);
            }
        }
    });
}

/*跳转数据列表页面*/
function gotoListPage(){
    location.href=getBasePath()+'/mdm/logipoint/list.htm';
}





